package net.disy.cadenza.repository.workflow;

import net.disy.cadenza.repository.wrappers.ParameterizedSelectorWrapper;
import net.disy.cadenza.repositorytree.schema.Item;

public class ParameterizedWorkflow {
	private Workflow workflow;
//	private Map<String, Set<String>> attributeParameterMap = new HashMap<String, Set<String>>();
//	private Map<String, String> keywordToObjectAttribute = new HashMap<String, String>();
//	private Set<SelectorCondition> workflowConditions = new HashSet<SelectorCondition>();
	private String parameters = "";
	
	private ParameterizedSelectorWrapper parameterizedSelector;
	
	private final String WORKFLOW_ID_TEMPLATE = "Show.RepositoryItem.Id=%s&";

	public ParameterizedWorkflow(Workflow workflow, ParameterizedSelectorWrapper parameterizedSelector){
		this.workflow = workflow;
		this.parameterizedSelector = parameterizedSelector;
	}
	
	public ParameterizedSelectorWrapper getParameterizedSelector() {
		return parameterizedSelector;
	}

	public void setParameterizedSelector(ParameterizedSelectorWrapper parameterizedSelector) {
		this.parameterizedSelector = parameterizedSelector;
	}

	public String getParameters() {
		return parameters;
	}
	
	public String getName(){
		return workflow.getName();
	}
	
	public Item getItem(){
		return workflow.getItem();
	}
	
	public String getURL(){
		StringBuffer url = new StringBuffer(String.format(WORKFLOW_ID_TEMPLATE, workflow.getItem().getId()));
		url.append(parameterizedSelector.getURL());
		if(url.toString().endsWith("&"))
			url.deleteCharAt(url.length() - 1);
		return url.toString();
	}
}
